<%@ page contentType="text/html;charset=UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="tags" tagdir="/WEB-INF/tags"%>
<c:set var="ctx" value="${pageContext.request.contextPath}" />
<html>
<head>
<title>流程配置</title>
<script type="text/javascript">
	var $grid, $win;
	$(function() {
		$win = $("#win").window({
			width : 800,
			height : 500,
			iniframe : true,
			autoVCenter : true,
			autoHCenter : true,
			closed : true
		});
		$grid = $("#grid").datagrid({
			method : "get",
			url : "${ctx}/bpm/confNode/dataGrid?search_EQ_bpmConfBase.id=${bpmConfBaseId}",
			idField : 'id',
			remoteSort : true,
			multiSort : true,
			singleSelect:true,
			fit : true,
			fitColumns : true,
			toolbar : '#tt',
			columns : [ [ {
				field : 'ck',
				checkbox : true
			}, {
				field : 'priority',
				title : '顺序',
				sortable : true
			}, {
				field : 'name',
				title : '节点名称'
			}, {
				field : 'code',
				title : '节点代码',
				sortable : true
			}, {
				field : 'type',
				title : '节点类型',
				sortable : true
			}, {
				field : 'confUser',
				title : '人员配置',
				align : 'center',
				formatter : function(value, row, index) {
					if (row.type == "userTask") {
						return "<a class='user-btn' href='#' onclick='userConf(\"" + row.id + "\",\"" + row.name + "\")'></a>";
					} else {
						return "";
					}
				}
			}, {
				field : 'confListener',
				title : '监听器配置',
				align : 'center',
				formatter : function(value, row, index) {
					return "<a class='listener-btn' href='#' onclick='listenerConf(\"" + row.id + "\",\"" + row.name + "\")'></a>";
				}
			}, {
				field : 'confForm',
				title : '表单配置',
				align : 'center',
				formatter : function(value, row, index) {
					if (row.type == "userTask" || row.type == "process") {
						return "<a class='form-btn' href='#' onclick='formConf(\"" + row.id + "\",\"" + row.name + "\")'></a>";
					} else {
						return "";
					}
				}
			}, {
				field : 'confOperation',
				title : '操作配置',
				align : 'center',
				formatter : function(value, row, index) {
					if (row.type == "userTask") {
						return "<a class='operation-btn' href='#' onclick='operationConf(\"" + row.id + "\",\"" + row.name + "\")'></a>";
					} else {
						return "";
					}
				}
			}, {
				field : 'confNotice',
				title : '提醒配置',
				align : 'center',
				formatter : function(value, row, index) {
					if (row.type != "process") {
						return "<a class='notice-btn' href='#' onclick='noticeConf(\"" + row.id + "\",\"" + row.name + "\")'></a>";
					} else {
						return "";
					}
				}
			} ] ],
			enableHeaderClickMenu : true,
			//此属性开启表头列名称右侧那个箭头形状的鼠标左键点击菜单
			enableHeaderContextMenu : true,
			//此属性开启表头列名称右键点击菜单
			enableRowContextMenu : false,
			onLoadSuccess : function(data) {
				$('.user-btn').linkbutton({
					iconCls : 'icon-cologne-user',
					plain : true
				});
				$(".listener-btn").linkbutton({
					iconCls : 'icon-cologne-product',
					plain : true
				});
				$(".form-btn").linkbutton({
					iconCls : 'icon-cologne-order-1',
					plain : true
				});
				$(".operation-btn").linkbutton({
					iconCls : 'icon-cologne-edit',
					plain : true
				});
				$(".notice-btn").linkbutton({
					iconCls : 'icon-cologne-lightbulb',
					plain : true
				});
			}
		});
		$("#userConfReset").click(function() {
			$.get("${ctx}/bpm/process/updateConfUser?bpmProcessId=${bpmProcessId}", function(result) {
				$.messager.show({
					msg : result.msg,
					icon : "info",
					position : "bottomRight"
				});
			}, 'json');
		});
		$("#formConfReset").click(function() {
			$.get("${ctx}/bpm/process/updateConfForm?bpmProcessId=${bpmProcessId}", function(result) {
				$.messager.show({
					msg : result.msg,
					icon : "info",
					position : "bottomRight"
				});
			}, 'json');
		});
		$("#operationConfReset").click(function() {
			$.get("${ctx}/bpm/process/updateConfOperation?bpmProcessId=${bpmProcessId}", function(result) {
				$.messager.show({
					msg : result.msg,
					icon : "info",
					position : "bottomRight"
				});
			}, 'json');
		});
	});
	function userConf(nodeId, nodeName) {
		$win.window("open").window("setTitle", "[" + nodeName + "]用户配置").window("refresh", "${ctx}/bpm/confUser?bpmConfNodeId=" + nodeId);
	}
	function formConf(nodeId, nodeName) {
		$win.window("open").window("setTitle", "[" + nodeName + "]表单配置").window("refresh", "${ctx}/bpm/confForm?bpmConfNodeId=" + nodeId);
	}
	function operationConf(nodeId, nodeName) {
		$win.window("open").window("setTitle", "[" + nodeName + "]操作配置").window("refresh",
				"${ctx}/bpm/confOperation?bpmConfNodeId=" + nodeId);
	}
	function listenerConf(nodeId, nodeName) {
		$win.window("open").window("setTitle", "[" + nodeName + "]监听器配置").window("refresh",
				"${ctx}/bpm/confListener?bpmConfNodeId=" + nodeId);
	}
	function noticeConf(nodeId, nodeName) {
		$win.window("open").window("setTitle", "[" + nodeName + "]邮件提醒配置").window("refresh",
				"${ctx}/bpm/confNotice?bpmConfNodeId=" + nodeId);
	}
</script>
</head>

<body>
	<div data-options="region:'center',fit:true,border:false">
		<table id="grid">
		</table>
	</div>
	<div id="tt" class="easyui-toolbar">
		<a id="userConfReset" class="easyui-linkbutton" data-options="plain: true, iconCls: 'icon-cologne-user'">人员配置还原</a> <a id="formConfReset"
			class="easyui-linkbutton" data-options="plain: true, iconCls: 'icon-cologne-order-1'">表单配置还原</a> <a id="operationConfReset"
			class="easyui-linkbutton" data-options="plain: true, iconCls: 'icon-cologne-edit'">操作配置还原</a>
	</div>

	<div id="win"></div>
</body>
</html>
